<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use DB;

class Workqrcode extends Model
{
    protected $table = 'work_qrcode';
    protected $primaryKey = 'id';

    public static function workQrcodeDetial($kfid)
    {
        return self::where("kfid",$kfid)->first();
    }

    public static function apiWorkQrcode($kfid)
    {
        return self::select("switch","upper","daily","qrcode_title","qrcode_style","qrcode_nike","qrcode_head_img","qrcode_describe","qrcode_notice","device_bind")->where("kfid",$kfid)->first();
    }

    public static function createWorkQrcode($kfid,$switch,$upper,$daily,$qrcode_style,$qrcode_title,$qrcode_nike,$qrcode_head_img,$qrcode_describe,$qrcode_notice)
    {
        return self::insert(["kfid"=>$kfid,"switch"=>$switch,"upper"=>$upper,"daily"=>$daily,"qrcode_style"=>$qrcode_style,"qrcode_title"=>$qrcode_title,"qrcode_nike"=>$qrcode_nike,"qrcode_head_img"=>$qrcode_head_img,"qrcode_describe"=>$qrcode_describe,"qrcode_notice"=>$qrcode_notice,"created_at"=>time()]);
    }

    public static function updateWorkQrcode($kfid,$switch,$upper,$daily,$qrcode_style,$qrcode_title,$qrcode_nike,$qrcode_head_img,$qrcode_describe,$qrcode_notice)
    {
        return self::where("kfid",$kfid)->update(["kfid"=>$kfid,"switch"=>$switch,"upper"=>$upper,"daily"=>$daily,"qrcode_style"=>$qrcode_style,"qrcode_title"=>$qrcode_title,"qrcode_nike"=>$qrcode_nike,"qrcode_head_img"=>$qrcode_head_img,"qrcode_describe"=>$qrcode_describe,"qrcode_notice"=>$qrcode_notice]);
    }
}
